package tests;

import static org.junit.Assert.*;

import java.sql.Timestamp;
import java.util.Date;

import model.Meeting;
import model.MeetingBuilder;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
 * This class tests the Meeting Builder class
 * 
 * @author b_aldosa
 *
 */
public class TestMeetingBuilder {

	MeetingBuilder SUT;
	Date date;
	Timestamp currentTime;
	Meeting meeting;
	
	/**
	 * This method is called before each test case to initialize
	 * the objects
	 */
	@Before
	public void setUp()
	{
		SUT=new MeetingBuilder();
		date= new Date();
		currentTime=(new Timestamp(date.getTime()));
		meeting=SUT.setAttendees("attendees")
				.setDescription("description")
				.setEnd(currentTime)
				.setStart(currentTime)
				.setLocation("location")
				.setOwner("owner")
				.setRevisionId(0)
				.setTopic("topic")
				.build();	
	}
	/**
	 * This method is called after every test case
	 * to nullify the objects
	 */
	@After
	public void tearDown()
	{
		SUT=null;
		date=null;
		currentTime=null;
		meeting=null;
	}
	/**
	 * This test case tests the set owner method
	 */
	@Test
	public void testSetOwner() {
		SUT.setOwner("owner");
		assertEquals("owner",SUT.getOwner());
	}
	/**
	 * This test case tests the set revision id method
	 */
	@Test
	public void testSetRevisionId() {
		SUT.setRevisionId(0);
		assertEquals(0,SUT.getRevisionId());
	}
	/**
	 * This test case tests the set topic method
	 */
	@Test
	public void testSetTopic() {
		SUT.setTopic("topic");
		assertEquals("topic",SUT.getTopic());
	}
	/**
	 * This test case tests the set location method
	 */
	@Test
	public void testSetLocation() {
		SUT.setLocation("location");
		assertEquals("location",SUT.getLocation());
	}
	/**
	 * This test case tests the set start method
	 */
	@Test
	public void testSetStart() {
		SUT.setStart(currentTime);
		assertEquals("class java.sql.Timestamp",SUT.getStart().getClass().toString());
	}
	/**
	 * This test case tests the set end method
	 */
	@Test
	public void testSetEnd() {
		SUT.setEnd(currentTime);
		assertEquals("class java.sql.Timestamp",SUT.getEnd().getClass().toString());
	}
	/**
	 * This test case tests the set attendees method
	 */
	@Test
	public void testSetAttendees() {
		SUT.setAttendees("attendees");
		assertEquals("attendees",SUT.getAttendees());
	}
	/**
	 * This test case tests the set description method
	 */
	@Test
	public void testSetDescription() {
		SUT.setDescription("description");
		assertEquals("description",SUT.getDescription());
	}
	/**
	 * This test case tests the build method
	 */
	@Test
	public void testBuild() {
		meeting=SUT.setAttendees("attendees")
				.setDescription("description")
				.setEnd(currentTime)
				.setStart(currentTime)
				.setLocation("location")
				.setOwner("owner")
				.setRevisionId(0)
				.setTopic("topic")
				.build();
		assertEquals("class model.Meeting", meeting.getClass().toString());
	}


}
